package io.renren.modules.recorderReport.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;
import io.renren.modules.recorderReport.entity.ReportAuditEntity;
import io.renren.modules.recorderReport.entity.TBaseLocationEntity;
import io.renren.modules.recorderReport.service.ReportAuditService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("recorderReport/reportAudit")
public class ReportAuditController {

    @Autowired
    ReportAuditService reportAuditService;

    /**
     * 举报信息列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("recorderReport:reportAudit:list")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);

        List<ReportAuditEntity> reportAuditList = reportAuditService.queryList(query);
        int total = reportAuditService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(reportAuditList, total, query.getLimit(), query.getCurrPage());

        return R.ok().put("page", pageUtil);
    }


    /**
     * 查询违法路段信息列表
     */
    @RequestMapping("/listTBaseLocations")
    public R listTBaseLocations(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);
        List<TBaseLocationEntity> tBaseLocationList = reportAuditService.likeForStreetPage(query);
        int total = reportAuditService.queryTotalStreet(query);

        PageUtils pageUtil = new PageUtils(tBaseLocationList, total, query.getLimit(), query.getCurrPage());


        return R.ok().put("page", pageUtil);
    }


    /**
     * 修改上报信息保存
     */
    @RequestMapping("/updateReportAuditSave")
    @RequiresPermissions("recorderReport:reportAudit:save")
    public R updateReportAuditSave(@RequestBody ReportAuditEntity reportAudit){

        reportAuditService.updateReportAuditSave(reportAudit);

        return R.ok();
    }

















}
